﻿/*******************************************************************************
 * AAEngine
 * Copyright (c) 2010 Mike Jarosch
 *
 * Original source PushButton Engine:
 * Copyright (C) 2009 PushButton Labs, LLC
 * For more information see http://www.pushbuttonengine.com
 *
 * This file is licensed under the terms of the MIT license, which is included
 * in the "MIT License.txt" file at the root directory of this SDK.
 ******************************************************************************/

namespace AAEngine.Engine.Entities
{
    /// <summary>
    /// A component is used to define specific pieces of functionality for    
    /// game entities. Several components can be added to a single entity to give    
    /// the entity complex behavior while keeping the different functionalities separate    
    /// from each other.
    /// </summary>
    /// <remarks>
    /// A full featured implementation of this interface is included (EntityComponent).    
    /// It should be adequate for almost every situation, and therefore, custom components    
    /// should derive from it rather than implementing this interface directly.
    /// 
    /// There are several reasons why it is set up this way:    
    /// * Entities have only the data they need and nothing more.
    /// * Components can be reused on several different types of entities.
    /// * Programmers can focus on specific pieces of functionality when writing code.  
    /// </remarks>
    public interface IEntityComponent
    {
        /// <summary>
        /// A reference to the entity that this component currently belongs to. If       
        /// the component has not been added to an entity, this will be null.
        /// </summary>
        /// <remarks>
        /// This value should be equivalent to the first parameter passed to the register       
        /// method.
        /// </remarks>
        IEntity Owner { get; set; }

        /// <summary>
        /// The name given to the component when it is added to an entity.
        /// </summary>
        /// <remarks>
        /// This value should be equivelent to the second parameter passed to the register       
        /// method.
        /// </remarks>
        string Name { get; }

        /// <summary>
        /// Whether or not the component is currently registered with an entity.
        /// </summary>
        bool IsRegistered { get; }

        /// <summary>
        /// Registers the component with an entity. This should only ever be called by      
        /// an IEntity from the addComponent method.
        /// </summary>
        /// <param name="owner">The entity to register the component with.</param>
        /// <param name="name">The name to assign to the component.</param>
        void Register(IEntity owner, string name);

        /// <summary>
        /// Unregisters the component from an entity. This should only ever be called by       
        /// an entity class from the removeComponent method.
        /// </summary>
        void Unregister();

        /// <summary>
        /// This is called by an entity on all of its components any time a component      
        /// is added or removed. In this method, any references to properties on the       
        /// owner entity should be purged and re-looked up.
        /// </summary>
        void Reset();
    }
}
